package cn.jeefast.rest.service.impl;

import cn.jeefast.common.entity.MbResearchStepDataTemplateMainIndicators;
import cn.jeefast.common.entity.MbResearchStrpDataTemplate;
import cn.jeefast.common.utils.R;
import cn.jeefast.rest.dao.MbResearchStepDataTemplateAnotherIndicatorsDao;
import cn.jeefast.rest.dao.MbResearchStepDataTemplateMainIndicatorsDao;
import cn.jeefast.rest.dao.MbResearchStepDataTemplateObjectiveIndicatorsDao;
import cn.jeefast.rest.dao.MbResearchStrpDataTemplateDao;
import cn.jeefast.rest.service.MbResearchStepDataTemplateAnotherIndicatorsService;
import cn.jeefast.rest.service.MbResearchStepDataTemplateObjectiveIndicatorsService;
import cn.jeefast.rest.service.MbResearchStrpDataTemplateService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author theodo
 * @since 2019-12-30
 */
@Service
public class MbResearchStrpDataTemplateServiceImpl extends ServiceImpl<MbResearchStrpDataTemplateDao, MbResearchStrpDataTemplate> implements MbResearchStrpDataTemplateService {

    /**
     * 主观指标DAO
     */
    @Autowired
    private MbResearchStepDataTemplateMainIndicatorsDao mbResearchStepDataTemplateMainIndicatorsDao;

    /**
     * 客观指标DAO
     */
    @Autowired
    private MbResearchStepDataTemplateObjectiveIndicatorsDao mbResearchStepDataTemplateObjectiveIndicatorsDao;

    /**
     * 其他指标
     */
    @Autowired
    private MbResearchStepDataTemplateAnotherIndicatorsDao mbResearchStepDataTemplateAnotherIndicatorsDao;

    /**
     * 根据模板ID获取指标详细信息
     * @param tempId
     * @return
     */
    @Override
    public R templateDeatilByTempId(Long tempId) {
        //获取主观指标
        EntityWrapper mi = new EntityWrapper();
        mi.eq("temp_id",tempId);
        List miList = mbResearchStepDataTemplateMainIndicatorsDao.selectList(mi);
        //获取客观指标
        EntityWrapper oi = new EntityWrapper();
        oi.eq("temp_id",tempId);
        List oiList = mbResearchStepDataTemplateObjectiveIndicatorsDao.selectList(oi);
        //获取其他指标
        EntityWrapper ai = new EntityWrapper();
        ai.eq("temp_id",tempId);
        List aiList = mbResearchStepDataTemplateAnotherIndicatorsDao.selectList(ai);
        Map map = new HashMap();
        map.put("mi",miList);
        map.put("oi",oiList);
        map.put("ai",aiList);
        return R.ok("").put("data",map);
    }
}
